﻿// owner 蒋家伟

#pragma once
#include <QDialog>
#include <string>
#include <map>
#include "OwnerPtr.h"

class QLineEdit;
class QPlainTextEdit;
class QPushButton;

namespace jsdk
{
    class  Dbg_Warn_Dlg : public QDialog
    {
        Q_OBJECT
    public:
        ~Dbg_Warn_Dlg() {}
        static OwnerPtr<Dbg_Warn_Dlg> create();
    public:
        /// \brief 显示dbg_warn对话框
        /// \ in filePath        文件路径
        /// \ in function        函数名称
        /// \ in rowNumber       行数
        /// \ in ownerName       作者
        /// \ in time            时间
        /// \ in description     异常描述
        void show(const std::wstring& filePath, 
            const std::wstring& function, 
            const uint32_t rowNumber,
            const std::wstring& ownerName, 
            const std::wstring& time, 
            const std::wstring& description
        );

        /// \ brief 是否全部忽略
        bool isAlwaysIgnored(const std::wstring& warnKey) const;

    private:
        void setCurrentWarnAlwaysIgnore();

    private:
        Dbg_Warn_Dlg(QWidget *parent = nullptr);

        // 面板显示控件
        QPlainTextEdit* m_pFilePathLineEdit = nullptr;
        QPlainTextEdit* m_pFunctionLineEdit = nullptr;
        QLineEdit* m_pRowNumberLineEdit = nullptr;
        QLineEdit* m_pOwnerLineEdit = nullptr;
        QLineEdit* m_pTimeLineEdit = nullptr;
        QPlainTextEdit* m_pDescriptionLineEdit = nullptr;

        // 按钮控件
        QPushButton* m_IgnoredBtn = nullptr;
        QPushButton* m_AlwaysIgnoredBtn = nullptr;
        QPushButton* m_DebugBtn = nullptr;

        // 所有异常警告的记录
        std::map<std::wstring, bool> m_warnKeyToIsAlwaysIgnored;
        std::wstring m_currentWarnKey;
    };
}